#define _CRT_SECURE_NO_WARNINGS



#include<iostream>
using namespace std;
const int N = 1010;
int n, m;
int a[N][N];
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    int h, w;
    cin >> h >> w;
    int flag = 0;
    for (int i = 1; i <= n - h + 1; i++)
    {
        for (int j = 1; j <= m - w + 1; j++)
        {
            if (a[i][j] == a[i][j + w - 1] && a[i][j + w - 1] == a[i + h - 1][j] && a[i + h - 1][j] == a[i + h - 1][j + w - 1])
            {
                flag = 1;
                break;
            }
        }
        if (flag)
        {
            cout << "YES";
            break;
        }
    }
    if (!flag)
        cout << "NO";
    return 0;
}